<?php
function view_profil($id){
	view_header_top();
	$user = getUser($id);
	//----------------------------------------------------------------
	$title = "Realita - ".$user['nama'];
	$content = "Realita ".$user['nama'];
	$url = PROFIL_URL."a/".$user['idFB'];
	$image = IMAGE_URL."300x240.gif";	//profpic orangnya / tokonya
	$desc = "Profil orangnya : ".$user['bio'];
	$auth = "RealiTA";
	$qwords = "profil, marketplace, umkm".$user['nama'];
	//----------------------
	echo "<title>$title</title>";
	//<!--META DATA Open Graph-->
	echo "<meta property=\"og:title\" content=\"$title\"/>";
	echo "<meta property=\"og:type\" content=\"$content\"/>";
	echo "<meta property=\"og:url\" content=\"$url\"/>";
	echo "<meta property=\"og:image\" content=\"$image\"/>";
	echo "<meta property=\"og:site_name\" content=\"RealiTA UMKM\"/>";
	echo "<meta property=\"og:description\" content=\"$desc\" />";
	//<!--META DATA FB-->
	echo "<meta property=\"fb:app_id\" content=\"147346958657510\" />";
	//<!--META DATA-->
	echo "<meta name=\"author\" content=\"$auth\" />";
	echo "<meta name=\"keywords\" content=\"$qwords\" />";
	echo "<meta name=\"description\" content=\"$desc\" />";
	echo "<meta name=\"robots\" content=\"ALL\" />";
	echo "<meta charset=\"UTF-8\" />";
	//----------------------------------------------------------------
	view_header_bottom();
?>
<!-- Content -->
	<div class="row">    
		<!-- Main Content Section -->
		<div class="large-9 push-3 columns">		  
		  <h3><?php echo $user['nama']; ?></h3>
		  <?php
			  if (isset($_SESSION['message'])) {
					echo "<div class='alert-box success'>".$_SESSION['message']."<a href='#' class='close'>&times;</a></div>";
					unset($_SESSION['message']);
			}
			?>
		  <hr />
		  <p><?php echo $user['bio']; ?></p>
		  <p>Logo FB <?php echo "<a href=\"http://facebook.com/".$user['fb_username']."\" target=\"_blank\">".$user['fb_username']."</a>"; ?></p>
		  <?php
		  if (isset($_SESSION['logged'])){
			if ($user['idFB']==$_SESSION['logged']['id']) {
				echo "<a href=\"".PROFIL_URL."edit/profil\">[Ubah Profil]</a>";
			}
		}
		  ?>
		  <hr />
          <p>Level Pengguna (rating)</p>
          <hr />
          <p>Relasi Teman (mutual friend,10 facepiles)</p>
          <hr />
          <p>Relasi Toko (daftar toko telah transaksi,10 facepiles)</p>
		</div>
		<!-- Nav Sidebar -->
		<!-- This is source ordered to be pulled to the left on larger screens -->
		<?php view_tab($user); ?>
	  </div>
    <!-- End Content -->
<?php
	view_footer();
}

function edit_profil(){
	view_header_top();
	$id = $_SESSION['logged']['id'];
	$user = getUser($_SESSION['logged']['id']);
	//----------------------------------------------------------------
	$title = "Realita - ".$user['nama'];
	$content = "Realita ".$user['nama'];
	$url = PROFIL_URL."a/".$user['idFB'];
	$image = IMAGE_URL."300x240.gif";	//profpic orangnya / tokonya
	$desc = "Profil orangnya : ".$user['bio'];
	$auth = "RealiTA";
	$qwords = "profil, marketplace, umkm".$user['nama'];
	//----------------------
	echo "<title>$title</title>";
	//<!--META DATA Open Graph-->
	echo "<meta property=\"og:title\" content=\"$title\"/>";
	echo "<meta property=\"og:type\" content=\"$content\"/>";
	echo "<meta property=\"og:url\" content=\"$url\"/>";
	echo "<meta property=\"og:image\" content=\"$image\"/>";
	echo "<meta property=\"og:site_name\" content=\"RealiTA UMKM\"/>";
	echo "<meta property=\"og:description\" content=\"$desc\" />";
	//<!--META DATA FB-->
	echo "<meta property=\"fb:app_id\" content=\"147346958657510\" />";
	//<!--META DATA-->
	echo "<meta name=\"author\" content=\"$auth\" />";
	echo "<meta name=\"keywords\" content=\"$qwords\" />";
	echo "<meta name=\"description\" content=\"$desc\" />";
	echo "<meta name=\"robots\" content=\"ALL\" />";
	echo "<meta charset=\"UTF-8\" />";
	//----------------------------------------------------------------
	view_header_bottom();
?>
<!-- Content -->
	<div class="row">    
		<!-- Main Content Section -->
		<!-- This has been source ordered to come first in the markup (and on small devices) but to be to the right of the nav on larger screens -->
		<div class="large-9 push-3 columns">		  
		  <h3><?php echo $user['nama']; ?></h3>
		  <?php
			  if (isset($_SESSION['message'])) {
					echo "<div class='alert-box alert'>".$_SESSION['message']."<a href='#' class='close'>&times;</a></div>";
					unset($_SESSION['message']);
			}
			?>
		  <hr />
		  <h4>Edit Profil</h4>
		  <form method="post" action="">
			<input type="hidden" name="index" value="<?php echo $user['idPengguna'] ?>" />
			<input type="hidden" name="idfb" value="<?php echo $user['idFB'] ?>" />
			<div class="large-12 columns">
				<div class="row">
					<div class="large-5 columns">
						<label>Nama</label>
						<input type="text" name="nama" placeholder="Nama..." value="<?php echo $user['nama'] ?>" />
					  </div>
				</div>
				<div class="row">
					<div class="large-3 columns">
						<label>Kontak</label>
						<input type="text" name="kontak" placeholder="08..." value="<?php echo $user['kontak'] ?>" />
					  </div>
				</div>
				<div class="row">
					<div class="large-5 columns">
						<label>Email</label>
						<input type="text" name="email" placeholder="xxx@yyy.ccc..." value="<?php echo $user['email'] ?>" />
					  </div>
				</div>
				<div class="row">
					<div class="large-10 columns">
						<label>Deskripsi</label>
						<textarea name="desc" placeholder="deskripsi singkat profil..."><?php echo $user['bio'] ?></textarea>
					  </div>
				</div>
				<div class="row">
					<div class="large-12 columns">
						<input class="button" name="edit-profil" type="submit" value="Ubah Profil" />
					  </div>
				</div>
			</div>
		  </form>
		</div>
		<!-- Nav Sidebar -->
		<!-- This is source ordered to be pulled to the left on larger screens -->
		<?php view_tab($user); ?>
	  </div>
    <!-- End Content -->
<?php
	view_footer();
}
